//
//  CZQCommentDetaiVC.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/22.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "CZQCommentDetaiVC.h"
#import "CZQHomeVIPCommentCell.h"
#import "SKTagView.h"
#import "CZQHomeTimeTableViewCell.h"
@interface CZQCommentDetaiVC ()<UITableViewDelegate,UITableViewDataSource>
/**
 //数据源
 */
@property(nonatomic,strong)NSMutableArray *dataArr;

/**
 tableView
 */
@property(nonatomic,weak)UITableView *tableView;
@end

@implementation CZQCommentDetaiVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"评价详情";
    
    [self tableView];
    
    // Do any additional setup after loading the view.
}



#pragma mark -- 懒加载

-(NSMutableArray *)dataArr
{
    if (!_dataArr) {
        
        _dataArr = [NSMutableArray array];
        
    }
    
    return _dataArr;
}

-(UITableView *)tableView
{
    if (!_tableView) {
        
        UITableView *tableView=[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        
        tableView.delegate=self;
        
        tableView.dataSource=self;
        
        tableView.backgroundColor = BackGroundColor;
        
        tableView.estimatedRowHeight = 150;
        
        [self.view addSubview:tableView];
        
        [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.edges.mas_equalTo(self.view);
            
        }];
        
        //        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        
        //注册
        [tableView registerClass:[CZQHomeVIPCommentCell class] forCellReuseIdentifier:@"CZQHomeVIPCommentCell"];
        
//        [tableView registerClass:[CZQHomeTimeTableViewCell class] forHeaderFooterViewReuseIdentifier:@"head"];
        
        //        [tableView registerNib:[UINib nibWithNibName:@"YDTrainingTableViewCell" bundle:nil]  forCellReuseIdentifier:@"cell"];
        
        //        [tableView registerNib:[UINib nibWithNibName:@"YDTrainingTableViewCell" bundle:nil]  forCellReuseIdentifier:@"cell"];
        
        _tableView = tableView;
    }
    return _tableView;
}

#pragma mark - UITableViewDataSource

//行数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

//列数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 9;
}

//cell内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CZQHomeVIPCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CZQHomeVIPCommentCell"];
    
    
    
    return cell  ;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
    return 50;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.00001;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [[UIView alloc]initWithFrame:CGRectZero];
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    WS(weakSelf);
    
    CZQHomeTimeTableViewCell *head = [CZQHomeTimeTableViewCell new];
    
    head.backgroundColor = CSWhiteColor;
    
    head.tagView.backgroundColor = CSWhiteColor;
    // 整个tagView对应其SuperView的上左下右距离
    head.tagView.padding = UIEdgeInsetsMake(5, 5, 5, 5);
    // 上下行之间的距离
    head.tagView.lineSpacing = 10;
    // item之间的距离
    head.tagView.interitemSpacing = 10;
    
    head.tagView.regularHeight = 20;
    // 最大宽度
    head.tagView.preferredMaxLayoutWidth = kScreenWidth ;
    
    [head.tagView removeAllTags];
    // 开始加载
    NSArray *arrM = @[@"全部评价",@"好评",@"差评",@"中评"];
    
    [arrM enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        // 初始化标签
        SKTag *tag = [[SKTag alloc] initWithText:arrM[idx]];
        // 标签相对于自己容器的上左下右的距离
        tag.padding = UIEdgeInsetsMake(5, 5, 5, 5);
        // 弧度
        tag.cornerRadius = 10.0f;
        // 字体
        tag.font = [UIFont boldSystemFontOfSize:13];
        // 边框宽度
        tag.borderWidth = 1;
        // 背景
        //        tag.bgColor = [UIColor colorWithRed:244/255.0 green:244/255.0 blue:244/255.0 alpha:1];
        // 边框颜色
        tag.borderColor = CSColorFromRGB(0xdbdbdb);
        // 字体颜色
        tag.textColor = BlackColor;
        // 是否可点击
        tag.enable = YES;
        // 加入到tagView
        [head.tagView addTag:tag];
    }];
    
    
    return head;
}



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //当离开某行时，让某行的选中状态消失
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
